package cn.anxingongyou.anxin.service.impl;

import cn.anxingongyou.anxin.entity.Industry;
import cn.anxingongyou.anxin.mapper.IndustryMapper;
import cn.anxingongyou.anxin.service.IndustryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IndustryServiceImpl implements IndustryService {

    private final IndustryMapper industryMapper;
    @Autowired
    public IndustryServiceImpl(IndustryMapper industryMapper) {
        this.industryMapper = industryMapper;
    }

    @Override
    public int insert(Industry industry) {
        return industryMapper.insertSelective(industry);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return industryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Industry industry) {
        return industryMapper.updateByPrimaryKeySelective(industry);
    }

    @Override
    public Industry selectOne(Industry industry) {
        return industryMapper.selectOne(industry);
    }

    @Override
    public Industry selectOneByPrimaryKey(Long id) {
        return industryMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<Industry> page(int pageNum, int pageSize, Industry industry) {
        String orderBy = "id desc";
        PageHelper pageHelper = new PageHelper();
        pageHelper.startPage(pageNum,pageSize,orderBy);
        List<Industry> list = industryMapper.select(industry);
        PageInfo<Industry> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
